package cn.edu.zust.se.mvcdb.servlet;

import cn.edu.zust.se.mvcdb.service.UserService;
import cn.edu.zust.se.mvcdb.service.impl.UserServiceImpl;
import cn.edu.zust.se.mvcdb.servlet.base.BaseServlet;
import cn.edu.zust.se.mvcdb.vo.User;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import java.io.IOException;
import java.util.List;
@WebServlet(name = "userServlet",urlPatterns = "/users")
public class UserServlet extends BaseServlet {
    @Override
    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
//        UserService userService=(UserService) getServletContext().getAttribute("userService");
        List<User> users=userService.getAllUsers();
        req.setAttribute("users",users);
        req.getRequestDispatcher("users.jsp").forward(req,res);
    }
}
